package com.chenyaowei.web.controller.marketing;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.chenyaowei.common.annotation.Log;
import com.chenyaowei.common.core.controller.BaseController;
import com.chenyaowei.common.core.domain.AjaxResult;
import com.chenyaowei.common.enums.BusinessType;
import com.chenyaowei.marketing.domain.CywSkuBounds;
import com.chenyaowei.marketing.service.ICywSkuBoundsService;
import com.chenyaowei.common.utils.poi.ExcelUtil;
import com.chenyaowei.common.core.page.TableDataInfo;

/**
 * 商品sku积分Controller
 *
 * @author 陈耀威
 * @date 2023-11-28
 */
@RestController
@RequestMapping("/marketing/skuBounds")
public class CywSkuBoundsController extends BaseController
{
    @Autowired
    private ICywSkuBoundsService cywSkuBoundsService;

    /**
     * 查询商品sku积分列表
     */
    @PreAuthorize("@ss.hasPermi('product:skuBounds:list')")
    @GetMapping("/list")
    public TableDataInfo list(CywSkuBounds cywSkuBounds)
    {
        startPage();
        List<CywSkuBounds> list = cywSkuBoundsService.selectCywSkuBoundsList(cywSkuBounds);
        return getDataTable(list);
    }

    /**
     * 导出商品sku积分列表
     */
    @PreAuthorize("@ss.hasPermi('product:skuBounds:export')")
    @Log(title = "商品sku积分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CywSkuBounds cywSkuBounds)
    {
        List<CywSkuBounds> list = cywSkuBoundsService.selectCywSkuBoundsList(cywSkuBounds);
        ExcelUtil<CywSkuBounds> util = new ExcelUtil<CywSkuBounds>(CywSkuBounds.class);
        util.exportExcel(response, list, "商品sku积分数据");
    }

    /**
     * 获取商品sku积分详细信息
     */
    @PreAuthorize("@ss.hasPermi('product:skuBounds:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cywSkuBoundsService.selectCywSkuBoundsById(id));
    }

    /**
     * 新增商品sku积分
     */
    @PreAuthorize("@ss.hasPermi('product:skuBounds:add')")
    @Log(title = "商品sku积分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CywSkuBounds cywSkuBounds)
    {
        return toAjax(cywSkuBoundsService.insertCywSkuBounds(cywSkuBounds));
    }

    /**
     * 修改商品sku积分
     */
    @PreAuthorize("@ss.hasPermi('product:skuBounds:edit')")
    @Log(title = "商品sku积分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CywSkuBounds cywSkuBounds)
    {
        return toAjax(cywSkuBoundsService.updateCywSkuBounds(cywSkuBounds));
    }

    /**
     * 删除商品sku积分
     */
    @PreAuthorize("@ss.hasPermi('product:skuBounds:remove')")
    @Log(title = "商品sku积分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cywSkuBoundsService.deleteCywSkuBoundsByIds(ids));
    }
}
